﻿using System;
using System.Web;
using System.Linq;
using GBlog.Core.Data;
using GBlog.Core.Entities;
using System.Collections.Generic;
namespace GBlog.Core.Service.Default
{
    public class UserService : ContentService<User>, IUserService
    {
        private IRepository<User> Repository { get; set; }
        public UserService(IRepository<User> Repository)
            : base(Repository)
        {
            this.Repository = Repository;
        }

        public User Current
        {
            get
            {
                User output = HttpContext.Current.User as User;
                return output;
            }
        }

        public User GetByUsername(string Username)
        {
            if (string.IsNullOrEmpty(Username))
            {
                return null;
            }
            return Repository.GetAll().FirstOrDefault(t => t.Username == Username);
        }
    }
}